package com.platform.comm.config;//package com.platform.comm.config;
//
//import com.platform.comm.config.properties.db.ZxDataSourceProperties;
//import com.zaxxer.hikari.HikariDataSource;
//import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.boot.context.properties.EnableConfigurationProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//import org.springframework.util.StringUtils;
//
//import javax.sql.DataSource;
//
///**
// * Description: 租户数据源配置
// *
// * @author libin created on 2021/4/20.
// */
//@Configuration
//@EnableConfigurationProperties({DataSourceProperties.class, ZxDataSourceProperties.class})
//public class MultipleDataSourceAutoConfiguration {
//
//    @Bean
//    @Primary
//    @ConfigurationProperties(prefix = "spring.datasource")
//    public HikariDataSource dataSource(DataSourceProperties properties) {
//        HikariDataSource dataSource = properties.initializeDataSourceBuilder().type(HikariDataSource.class).build();
//        if (StringUtils.hasText(properties.getName())) {
//            dataSource.setPoolName(properties.getName());
//        }
//        dataSource.setMaximumPoolSize(10);
//        dataSource.setMinimumIdle(1);
//        dataSource.setPoolName("GP-master-DBPool");
//        dataSource.setIdleTimeout(600000);
//        dataSource.setConnectionTestQuery("SELECT 1");
//        dataSource.setMaxLifetime(1800000);
//        dataSource.setValidationTimeout(3000);
//        dataSource.setConnectionTimeout(60000);
//        dataSource.setInitializationFailTimeout(60000);
//        return dataSource;
//    }
//
//    @Bean("zxDataSource")
//    public DataSource zxDataSource(ZxDataSourceProperties zxDataSourceProperties) {
//        // 中心库数据源配置
//        HikariDataSource hikariDataSource = new HikariDataSource();
//        hikariDataSource.setDriverClassName(zxDataSourceProperties.getDriverClassName());
//        hikariDataSource.setJdbcUrl(zxDataSourceProperties.getUrl());
//        hikariDataSource.setUsername(zxDataSourceProperties.getUsername());
//        hikariDataSource.setPassword(zxDataSourceProperties.getPassword());
//        hikariDataSource.setMaximumPoolSize(50);
//        hikariDataSource.setMinimumIdle(1);
//        hikariDataSource.setPoolName("GP-zx-DBPool");
//        hikariDataSource.setIdleTimeout(30000);
//        hikariDataSource.setConnectionTestQuery("SELECT 1");
//        hikariDataSource.setMaxLifetime(600000);
//        hikariDataSource.setValidationTimeout(3000);
//        hikariDataSource.setConnectionTimeout(60000);
//        hikariDataSource.setInitializationFailTimeout(60000);
//        return hikariDataSource;
//    }
//
//}
